package com.sun.service.role;

import com.sun.dao.BaseDao;
import com.sun.dao.role.RoleDao;
import com.sun.dao.role.RoleDaoImpl;
import com.sun.pojo.Role;

import java.sql.Connection;
import java.util.List;

/**
 * @Author SunBingRui
 * @Date 2020/4/29 20:37
 */
public class RoleServiceImol implements RoleService {

    //角色业务层都会调用角色Dao层，所以需要引入RoleDao层
    private RoleDao roleDao;

    public RoleServiceImol(){
        roleDao = new RoleDaoImpl();
    }

    public List<Role> getRoleList() {

        Connection connection = null;
        List<Role> roleList = null;

        try {
            connection = BaseDao.getConnection();
            roleList = roleDao.getRoleList(connection);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            BaseDao.closeResource(connection, null, null);
        }

        return roleList;
    }


}
